<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%  String basepath = request.getContextPath(); %>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="<%=basepath%>/css/account.css" rel="stylesheet" type="text/css" />
		<link href="<%=basepath%>/css/register.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/include.js"></script>
		<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/register.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/common.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/utilTool.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/validatorTool.js"></script>

<style type="text/css">
.mycolor {
	color: #FF0000;
}
</style>

<script type="text/javascript">

function preStep() {
	document.forms[0].action = "<%=basepath %>/register/nopassEditPreStep?preStep=3";
	document.forms[0].submit();
}


function nextStep() {
	document.forms[0].action = "<%=basepath %>/register/nopassEditNextStep?nextStep=5";
	document.forms[0].submit();
}
	
function initBankType(id){
	var url = "iframe:<%=basepath%>/register/initBankTypeList?id="+id;
	dialog("", url,"500", "400", "","");
}

function initCurType(id){
	var url = "iframe:<%=basepath%>/register/initCurTypeList?id="+id;
	dialog("", url,"500", "400", "","");
}

//行号
var bankTypeIndex=${bankRows};

function addBankInfo() {
	var bankInfo = document.all("bankInfo");
	if(bankInfo != null) {
 		var row = bankInfo.insertRow();
 		bankTypeIndex++;
	 	row.style.height = '26px';
	 	row.id = "row"+bankTypeIndex;

		//序号
		var cell = row.insertCell()
		cell.innerHTML = "<input type='text'  class='list_text_2' name='index' value='"+bankTypeIndex+"'  readOnly/>";

		//银行账户
		var cell = row.insertCell()
		cell.innerHTML = "<input type='text' class='list_text_2' name='supaccount' />";
		
		//银行户名	
 		cell = row.insertCell()
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text'  class='list_text_2' name='accountname'/> <input type='hidden' class='textinput' name='memo'/>";
		 	
 		//银行分类名称
 		var cellId="bankType"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' name='bankTypeName' id='"+cellName+"' onclick=\"initBankType('"+cellId+"')\" readOnly class='list_text_2'/>";

		//银行户名	
		var cellId="bankDoc"+bankTypeIndex;
		cellName=cellId+"name";
 		cell = row.insertCell()
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' name='bankDocName' id='"+cellName+"' onclick=\"initBankDoc('"+cellId+"',"+bankTypeIndex+")\" readOnly class='list_text_2'/>";
		
 		//币种名称
 		var cellId="curtype"+bankTypeIndex;
 		
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' name='currencyName' id='"+cellName+"' onclick=\"initCurType('"+cellId+"')\" readOnly class='list_text_2'/>";

 		//删除操作
 		var cellId="bankType"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';   
 		cell.innerHTML = "<a id='row"+bankTypeIndex+"' href=\"javascript:deleteRow('"+bankTypeIndex+"')\" class='linkstyle3'>删除</a> <input type='hidden' name='bankTypeId' id='"+cellId+"'/><input type='hidden' name='pkCurrency' id='curtype"+bankTypeIndex+"'/> <input type='hidden' name='pk_supbankacc' value='' id='' /> <input type='hidden' name='pkBankDoc' id='bankDoc"+bankTypeIndex+"' /><input type='hidden' name='src_bankbas' value=''  />";
 		
 	}
}
//删除行
function deleteRow(index) {
	var root = document.all("bankInfo");
	var row = "row"+index ;
	var rows = root.rows;
	//var deletepos = 1;
	//寻找到对应的删除行并进行删除
	for(var pos = 1; pos < rows.length; pos++) {
		var temprow = rows[pos];
		if(temprow.id == row) {
			root.deleteRow(pos);
			//deletepos = pos;
			bankTypeIndex--;
			break;
		}
	}
	//当删除行操作时更新显示索引
	for(var pos = 1; pos < rows.length; pos++) {
		var temprow = rows[pos];
		var cells = temprow.cells;
		var cell = cells[0];
		if(typeof(cell) == 'object') {
			cell.innerHTML = "<input type='text' class='list_text_2' name='index' value='"+pos+"'  readOnly/>";
		}
	}	
}

function initBankDoc(id,index){
	var pkBankType=document.getElementById("bankType"+index).value;
	if(pkBankType==null || pkBankType==""){
		alert("请选择银行类别");
		return;
	}
	var url = "iframe:<%=basepath%>/register/initBankDocList?id="+id+"&pkBankType="+pkBankType;
	dialog("", url,"500", "400", "","");
}
</script>
	</head>
	<body class="fullbody">
		<div id="content" class="content">
			<div class="">
				<b class="rtop"><b class="r1"></b><b class="r2"></b>
					<b class="r3"></b><b class="r4"> </b> </b>
				<table cellpadding="0" cellspacing="0" border="0" width="980">
					<tr>
						<td class="leftmargin"></td>
						<td valign="top" align="left">
							<form method="post">
								<input type="hidden" name="src" value="${src}"/>
								<div class="productlist">
									<div  style="font-size:12"><b>供应商银行账号信息</b><font class="memoTh"> (此银行帐号供付款和收付投标保证金使用)</font></div>
									<div class="spliter_line"></div>
									<div class="margin10"></div>
								</div>
								<div>
									<table border="0" cellpadding="0" cellspacing="0" id="bankInfo"
										class="subpage_table1 withborder2" align="center" width="800">
										<tr> 
											<th class="w_04">序号</th>
											<th class="w_02">银行账号<span class="needfill">*</span></th>
											<th class="w_02">账户名称<span class="needfill">*</span></th>
											<th class="w_02">银行类别<span class="needfill">*</span></th>
											<th class="w_02">开户银行<span class="needfill">*</span></th>
											<th class="w_02">币种<span class="needfill">*</span></th>
											<th class="w_02">操作</th>
										</tr>
										<c:if test="${currentInfo!=null && currentInfo.bankAccVos!=null}">
											<c:forEach items="${currentInfo.bankAccVos}" var="bank" varStatus="index">
												<tr align="center" class="datarow" id="row${bank.index}">
													<td><input type="text" class="list_text_2" name="index" value="${bank.index}" id="index" readOnly/></td>
													<td><input type="text" class="list_text_2" name="supaccount" value="${bank.supaccount}" id="supaccount" /></td>
													<td>
														<input type="text" class="list_text_2" name="accountname" value="${bank.accountname}" id="accountname" />
													</td>
													<td>
														<input type="text" class="list_text_2" name="bankTypeName" value="${bank.bankTypeName}" 
															id="bankType${bank.index}name" onclick="initBankType('bankType${bank.index}')" readOnly />
													</td>
													<td>
														<input type="text" class="list_text_2" name="bankDocName" value="${bank.bankDocName}"
															id="bankDoc${bank.index}name" onclick="initBankDoc('bankDoc${bank.index}',${bank.index})" readOnly/></td>
													<td>
														<input type="text" class="list_text_2" name="currencyName" value="${bank.currencyName}" 
															id="curtype${bank.index}name" onclick="initCurType('curtype${bank.index}')" readOnly />
													</td>
													<td>
														<a id="row${bank.index}" href="javascript:deleteRow('${bank.index}')" class='linkstyle3' >删除</a>
														<input type="hidden" name="bankTypeId" value="${bank.bankTypeId}" id="bankType${bank.index}" />
														<input type="hidden" name="pkCurrency" value="${bank.pkCurrency}" id="curtype${bank.index}" />
														<input type="hidden" name="pk_supbankacc" value="${bank.pk_supbankacc}" id="pk_supbankacc" />
														<input type="hidden" name="pkBankDoc" value="${bank.pkBankDoc}" id="bankDoc${bank.index}" />
														<input type="hidden" name="src_bankbas" value="${bank.src_bankbas}"  />
													</td>
												</tr>
											</c:forEach>
										</c:if>
									</table>
									<br/>
									<br/>
									<table border="0" cellpadding="0" cellspacing="0" 
										  align="center" width="800">
										<tr class="buttonrow" >
											<td align="right" colspan="4" align="center" >
												<input type="button" value="增行" onclick="addBankInfo()" class="btnscs"/>
												&nbsp;&nbsp;
												<input type="button" value="上一步" onclick="preStep();"
													class="btnscs" />
												&nbsp;&nbsp;
												<input type="button" value="下一步" onclick="nextStep();"
													class="btnscs" />
											</td>
										</tr>
									</table>
								</div>
							</form>
						</td>
					</tr>
				</table>
				<div id="message" class="mycolor">
					<c:out value="${ERROR_MESSAGE}"></c:out>
				</div>
			</div>
		</div>
	</body>
</html>